<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    body {
        border: 1px solid #999;
        padding: 50px;
    }

    .box {
        display: flex;
        width: 100px;
        height: auto;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin: 20px;
        margin-right: 50px;
    }

    .demo {
        border: 1px solid red;
        background-color: aqua;
        height: 100px;
        width: 100px;
        display: inline-block;
    }

    .demo:hover {

        color: white;
    }
    .animation_d:hover{
        animation: myfirst 2s;
    }
    @keyframes myfirst{
        from{
            width: 150px;
            height: 150px;
        }
        to{
            width: 250px;
            height: 250px;
            background-color: maroon;
        }
    }
    .animation_d2:hover{
        animation: myfirst2 2s linear infinite alternate;
    }
    @keyframes myfirst2{
        0%{
            width: 120px;
            height: 120px;
            background-color: yellow;
        }
        25%{
            width: 140px;
            height: 140px;
            background-color: blue;
        }
        50%{
            width: 180px;
            height: 180px;
            background-color: green;
        }
        75%{
            width: 220px;
            height: 220px;
            background-color: orangered;
        }
        100%{
            width: 250px;
            height: 250px;
            background-color: maroon;
        }
    }
    .animation_d3{
        position: relative;
        /*animation: myfirst3 2s forwards;*/
    }
    .animation_d3:hover{

    }
    @keyframes myfirst3{
        0%{
            top:0;
            left:0;
            background-color: yellow;
        }
        25%{
            top:0;
            left:200px;
            background-color: yellow;
        }
        50%{
            top:200px;
            left:200px;
            background-color: blue;
        }
        75%{
            top:200px;
            left:0;
            background-color: green;
        }
        100%{
            top:0;
            left:0;
            background-color: maroon;
        }
    }

    .box4 {
      margin-left: 400px;
      width: 100px;
      height: 100px;
      border-radius: 50%;
      background: #0000FF;
      animation: roll1 3s;
    }
    @keyframes roll {
      0% {
        transform:translateX(0px);
      }
      10% {
        transform: rotateZ(90deg) translateY(100px);
        /* 角度旋转的时候 盒子的方向就会改变 原来正向是x轴，竖向是y轴，但角度改变时 x y 轴的方法就会随着变化  所以角度变化的时候 不能再按着原来x y轴的方向来设计了 */
      }
      30% {
        transform: translateX(600px);
      }
      50% {
        transform: translateX(400px);
      }
      100% {
        transform: translateX(800px);
      }
    }
    @keyframes roll1 {
      0% {
        transform:rotateZ(0deg)
      }
      10% {
        transform: rotateZ(90deg) translateX(500px); /* 角度偏向90度时，原来水平方向的x轴，变成垂直方向了，所以就会一下子往垂直方向掉下去 */
      }
      30% {
        transform: rotateZ(135deg)
      }
      50% {
        transform: rotateZ(275deg)
      }
      100% {
        transform: rotateZ(720deg)
      }
    }

</style>

<body>
    <div class="box">
        <span>animation @keyframes myfirst</span>
        <div class="demo animation_d">
            此处用来测试
        </div>
    </div>
    <div class="box">
        <span>animation @keyframes myfirst2</span>
        <div class="demo animation_d2">
            此处用来测试
        </div>
    </div>
    <div class="box">
        <span>animation @keyframes myfirst3</span>
        <div class="demo animation_d3">
            此处用来测试
        </div>
    </div>
    <br>
    <div class="box4">此处用来测试</div>
</body>

</html>
